import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

main() => runApp(MyApp());

// 生成代码快捷键  stl
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: GLHomePage(),
    );
  }
}

class GLHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Flutter列表"),
      ),
      body: ListView.separated(
        itemCount: 100,
        itemBuilder: (BuildContext ctx, int index) {
          return Text("Hello Flutter:$index", style: TextStyle(fontSize: 30));
        },
        separatorBuilder: (BuildContext ctx, int index) {
          return Divider(
            color: Colors.black,
            height: 10,
            indent: 10,
            endIndent: 10,
            thickness: 10, // 线高度
          );
        }, // 分割线
      ),
    );
  }
}

class ListViewDemo extends StatelessWidget {
  const ListViewDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      // scrollDirection: Axis.horizontal, // 水平滚动
      // itemExtent: 80, // Item高度
      children: List.generate(100, (index) {
        return ListTile(
          leading: Icon(Icons.movie),
          trailing: Icon(Icons.delete),
          title: Text("电影名称:{$index+1}"),
          subtitle: Text("大话西游"),
        );
      }),
    );
  }
}

class ListViewDemo2 extends StatelessWidget {
  const ListViewDemo2({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: 100,
      itemExtent: 60,
      itemBuilder: (BuildContext ctx, int index) {
        return Text("Hello Flutter:$index", style: TextStyle(fontSize: 30));
      },
    );
  }
}
